package com.zc.manager.notify.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.zc.manager.notify.domain.NotifyTemplate;
import org.springframework.stereotype.Service;
import com.zc.manager.notify.mapper.NotifyConfigMapper;
import com.zc.manager.notify.domain.NotifyConfig;
import com.zc.manager.notify.service.NotifyConfigService;

import javax.annotation.Resource;

/**
 * 通知配置Service业务层处理
 *
 * @author wangjiabao
 * @date 2022-11-10
 */
@Service
public class NotifyConfigServiceImpl implements NotifyConfigService {
    @Resource
    private NotifyConfigMapper notifyConfigMapper;

    /**
     * 查询通知配置
     *
     * @param id 通知配置主键
     * @return 通知配置
     */
    @Override
    public NotifyConfig selectNotifyConfigById(Long id) {
        return notifyConfigMapper.selectNotifyConfigById(id);
    }

    /**
     * 查询通知配置列表
     *
     * @param notifyConfig 通知配置
     * @return 通知配置
     */
    @Override
    public List<NotifyConfig> selectNotifyConfigList(NotifyConfig notifyConfig) {
        return notifyConfigMapper.selectNotifyConfigList(notifyConfig);
    }

    /**
     * 新增通知配置
     *
     * @param notifyConfig 通知配置
     * @return 结果
     */
    @Override
    public int insertNotifyConfig(NotifyConfig notifyConfig) {
        notifyConfig.setCreateTime(DateUtils.getNowDate());
        return notifyConfigMapper.insertNotifyConfig(notifyConfig);
    }

    /**
     * 修改通知配置
     *
     * @param notifyConfig 通知配置
     * @return 结果
     */
    @Override
    public int updateNotifyConfig(NotifyConfig notifyConfig) {
        notifyConfig.setUpdateTime(DateUtils.getNowDate());
        return notifyConfigMapper.updateNotifyConfig(notifyConfig);
    }

    /**
     * 批量删除通知配置
     *
     * @param ids 需要删除的通知配置主键
     * @return 结果
     */
    @Override
    public int deleteNotifyConfigByIds(Long[] ids) {
        return notifyConfigMapper.deleteNotifyConfigByIds(ids);
    }

    /**
     * 导入通知配置
     *
     * @param list 导入数据集
     * @return 结果
     */
    @Override
    public int importNotifyConfig(List<NotifyConfig> list) {
        int num = 0;
        for (NotifyConfig notifyConfig : list) {
            notifyConfig.setCreateTime(DateUtils.getNowDate());
            num = num + notifyConfigMapper.insertNotifyConfig(notifyConfig);
        }
        return num;
    }

}
